Commit graph

23 commits

Author SHA1 Message Date
Stan Hu
385aa46046 Cache Flipper persisted names directly to local memory storage
Now that application settings are no longer dominating network traffic,
we see that the Feature#persisted_names is using a significant amount of
CPU and network bandwidth for Redis. Move this cache into the
thread-local memory storage to reduce Redis overhead.
2019-07-02 07:26:27 -07:00
Stan Hu
1b0c71ef84 Cache feature flag names in Redis for a minute
We saw on GitLab.com, the SQL query, `SELECT "features"."key" FROM
"features"` peaked at 2300 times per second.

We can quiet this down a bit by caching it in Redis for a minute.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63435
2019-06-18 13:59:18 -07:00
James Edwards-Jones
46f66c7f0a Allow setting feature flags per GitLab group
Building on support for setting feature flags by project, this adds
support for setting them by GitLab group path.

This is different from setting them by Flipper feature_groups, which
are for batch updating pre-registered collections.
2019-02-19 14:57:03 +08:00
Zeger-Jan van de Weg
5396594a83
Allow setting of feature gates per project
For features the feature gates are sometimes projects, not groups or
users. For example for git object pools:
https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5872

This commit allows for setting feature group gates based on projects, by its
path as that seems most convenient.
2019-01-14 14:29:51 +01:00
gfyoung
d598e4fd93 Enable more frozen string in lib/**/*.rb
Enables frozen for the following:

* lib/*.rb
* lib/banzai/**/*.rb
* lib/bitbucket/**/*.rb
* lib/constraints/**/*.rb
* lib/container_registry/**/*.rb
* lib/declarative_policy/**/*.rb

Partially addresses #47424.
2018-10-06 17:02:50 -07:00
Douglas Barbosa Alexandre
75ddf0d48d
Refactor Feature.flipper method 2018-10-05 11:20:19 -03:00
Michael Kozono
74ae135888 Refactor Feature.flipper method
* Fix typo in context 'when request store is active'
* Rearrange test since the instance variable always gets set now,
even if RequestStore is active
2018-09-24 12:29:22 -07:00
Michael Kozono
f107bc69e3 Simplify by using Gitlab::SafeRequestStore
These are clear wins.
2018-09-24 12:11:26 -07:00
Brett Walker
e57d99947a remove guard clause and add comment on performace 2018-09-05 09:26:13 -05:00
Brett Walker
3aea946e7f add 'default_enabled' to feature flags
This allows you to default a feature flag to 'on' when
checking whether it's enabled/disabled.
2018-09-05 09:19:16 -05:00
Gabriel Mazetto
61c35b6ca1 Fixed stub_feature_flag behavior for disabled? flags.
Previous code would not work with `disabled?` because that method would
send two parameters (second always `nil`) which we are not mocking.

Instead of mock yet another state, I decide to fix it where it belongs.
2018-08-22 05:41:15 +02:00
Zeger-Jan van de Weg
79a5d76801
Add repository languages for projects
Our friends at GitHub show the programming languages for a long time,
and inspired by that this commit means to create about the same
functionality.

Language detection is done through Linguist, as before, where the
difference is that we cache the result in the database. Also, Gitaly can
incrementaly scan a repository. This is done through a shell out, which
creates overhead of about 3s each run. For now this won't be improved.

Scans are triggered by pushed to the default branch, usually `master`.
However, one exception to this rule the charts page. If we're requesting
this expensive data anyway, we just cache it in the database.

Edge cases where there is no repository, or its empty are caught in the
Repository model. This makes use of Redis caching, which is probably
already loaded.

The added model is called RepositoryLanguage, which will make it harder
if/when GitLab supports multiple repositories per project. However, for
now I think this shouldn't be a concern. Also, Language could be
confused with the i18n languages and felt like the current name was
suiteable too.

Design of the Project#Show page is done with help from @dimitrieh. This
change is not visible to the end user unless detections are done.
2018-08-01 18:58:29 +02:00
Douglas Barbosa Alexandre
06e03f6e4d
Allow feature flag names to be a symbol 2018-07-19 21:05:24 -03:00
Rémy Coutable
e1ffd6a271
Use RequestStore to memoize Flipper features so that memoized values are cleared between requests
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-06-01 17:51:40 +02:00
Rémy Coutable
2ad01c5ab0
Ensure Flipper memoizer is used in Sidekiq's context
Also, don't use the provided Middleware, which isn't thread-safe, and
instantiate a new Flipper instance per thread instead.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-05-18 12:25:54 +02:00
Rémy Coutable
b51e6d6ddc
Update flipper to 0.11.0 and take advantage of the new features
- Added an ActiveSupport (using Rails.cache) caching adapter
- Overview of the new features can be found at https://johnnunemaker.com/flippin-features-at-runtime/
- Full Changelog can be found at https://github.com/jnunemaker/flipper/blob/v0.11.0/Changelog.md

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-12-14 02:11:11 +01:00
Yorick Peterse
90be53c5d3
Cache feature names in RequestStore
The GitHub importer (and probably other parts of our code) ends up
calling Feature.persisted? many times (via Gitaly). By storing this data
in RequestStore we can save ourselves _a lot_ of database queries.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/39361
2017-11-07 22:28:57 +01:00
Rémy Coutable
a7d65aeaf2
Re-add Feature.register_feature_groups which is already documented
This is a follow-up for !12362 where this was documented but the code
was removed in the last iteration. Since this can still be useful and
this is already supported by the API, I think re-adding the code was
the best course of action.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-10 15:56:23 +02:00
Rémy Coutable
b4d325c80c Allow the feature flags to be enabled/disabled with more granularity
This allows to enable/disable a feature flag for a given user, or a
given Flipper group (must be declared statically in the `flipper.rb`
initializer beforehand).

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-27 18:59:51 +02:00
Robert Speicher
6661b0b8e0 Fix Style/EmptyLines violation in lib/feature.rb 2017-06-22 11:20:54 -05:00
Rémy Coutable
b8a7b59d82 Add the Flipper::Middleware::Memoizer middleware
This ensures we make maximum one call per feature per request.

See
https://github.com/jnunemaker/flipper/blob/v0.10.2/docs/Optimization.md#memoizing-middleware

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-21 17:35:29 +02:00
Sean McGivern
1d3c33b57e Increase diff limits to 100 KB for collapse and 200 KB overall
This is controlled with the feature flag gitlab_git_diff_size_limit_increase.
Both of these limits were basically picked arbitrarily in the first place;
disabling the feature flag reverts to the old limits.
2017-06-02 19:37:09 +01:00
Alejandro Rodríguez
671284ba37 Add feature toggles through Flipper 2017-05-31 21:06:01 +00:00