You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "PakhomovAlexander (via GitHub)" <gi...@apache.org> on 2025/01/07 15:46:34 UTC
[PR] IGNITE-24163 Optimize EventLog [ignite-3]
PakhomovAlexander opened a new pull request, #5004:
URL: https://github.com/apache/ignite-3/pull/5004
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#issuecomment-2578041675
<img width="1434" alt="Screenshot 2025-01-08 at 19 01 07" src="https://github.com/user-attachments/assets/bf34d8b2-f544-49e1-816e-bd0d0b3463d7" />
Benchmark results against baseline (single if statement).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1907213390
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/impl/ConfigurationBasedChannelRegistry.java:
##########
@@ -35,73 +34,57 @@
import org.apache.ignite.internal.eventlog.config.schema.ChannelView;
import org.apache.ignite.internal.eventlog.config.schema.EventLogConfiguration;
-class ConfigurationBasedChannelRegistry implements ChannelRegistry {
- private final ReadWriteLock guard;
+public class ConfigurationBasedChannelRegistry implements ChannelRegistry {
+ private final AtomicReference<Map<String, EventChannel>> cache;
- private final Map<String, EventChannel> cache;
-
- private final Map<String, Set<EventChannel>> typeCache;
+ private final AtomicReference<Map<String, Set<EventChannel>>> typeCache;
private final SinkRegistry sinkRegistry;
- ConfigurationBasedChannelRegistry(EventLogConfiguration cfg, SinkRegistry sinkRegistry) {
- this.guard = new ReentrantReadWriteLock();
- this.cache = new HashMap<>();
- this.typeCache = new HashMap<>();
+ public ConfigurationBasedChannelRegistry(EventLogConfiguration cfg, SinkRegistry sinkRegistry) {
+ this.cache = new AtomicReference<>(new HashMap<>());
+ this.typeCache = new AtomicReference<>(new HashMap<>());
this.sinkRegistry = sinkRegistry;
cfg.channels().listen(new CacheUpdater());
}
@Override
public EventChannel getByName(String name) {
- guard.readLock().lock();
- try {
- return cache.get(name);
- } finally {
- guard.readLock().unlock();
- }
+ return cache.get().get(name);
}
@Override
public Set<EventChannel> findAllChannelsByEventType(String igniteEventType) {
- guard.readLock().lock();
- try {
- Set<EventChannel> result = typeCache.get(igniteEventType);
- return result == null ? Set.of() : new HashSet<>(result);
- } finally {
- guard.readLock().unlock();
- }
+ Set<EventChannel> result = typeCache.get().get(igniteEventType);
+ return result == null ? Set.of() : new HashSet<>(result);
Review Comment:
Why? I return the collection outside and I do not want anybody to modify it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1905674295
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/api/EventLog.java:
##########
@@ -44,7 +44,16 @@ public interface EventLog {
/**
* Writes event into every channel this event relates to.
*
- * @param eventProvider Event provider.
+ * @param event the event to log.
Review Comment:
```suggestion
* @param event The event to log.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1905726441
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/impl/ConfigurationBasedChannelRegistry.java:
##########
@@ -35,73 +34,57 @@
import org.apache.ignite.internal.eventlog.config.schema.ChannelView;
import org.apache.ignite.internal.eventlog.config.schema.EventLogConfiguration;
-class ConfigurationBasedChannelRegistry implements ChannelRegistry {
- private final ReadWriteLock guard;
+public class ConfigurationBasedChannelRegistry implements ChannelRegistry {
+ private final AtomicReference<Map<String, EventChannel>> cache;
- private final Map<String, EventChannel> cache;
-
- private final Map<String, Set<EventChannel>> typeCache;
+ private final AtomicReference<Map<String, Set<EventChannel>>> typeCache;
Review Comment:
No AtomicReference is needed.
These can be plain volatile fields.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1906724792
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/api/EventLog.java:
##########
@@ -44,7 +44,16 @@ public interface EventLog {
/**
* Writes event into every channel this event relates to.
*
- * @param eventProvider Event provider.
+ * @param event The event to log.
*/
- void log(Supplier<Event> eventProvider);
+ void log(Event event);
+
+ /**
+ * Lazy version of {@link #log(Event)}. It first checks if the events of the given type are enabled and then logs the event.
+ * INVARIANT: type must be a valid event type and eventProvider must provide an event of the same type.
+ *
+ * @param type the type of the event.
+ * @param eventProvider the event provider.
+ */
+ void log(String type, Supplier<Event> eventProvider);
Review Comment:
Why do we use type as String instead of enum?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1905736856
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/impl/ConfigurationBasedChannelRegistry.java:
##########
@@ -35,73 +34,57 @@
import org.apache.ignite.internal.eventlog.config.schema.ChannelView;
import org.apache.ignite.internal.eventlog.config.schema.EventLogConfiguration;
-class ConfigurationBasedChannelRegistry implements ChannelRegistry {
- private final ReadWriteLock guard;
+public class ConfigurationBasedChannelRegistry implements ChannelRegistry {
+ private final AtomicReference<Map<String, EventChannel>> cache;
- private final Map<String, EventChannel> cache;
-
- private final Map<String, Set<EventChannel>> typeCache;
+ private final AtomicReference<Map<String, Set<EventChannel>>> typeCache;
private final SinkRegistry sinkRegistry;
- ConfigurationBasedChannelRegistry(EventLogConfiguration cfg, SinkRegistry sinkRegistry) {
- this.guard = new ReentrantReadWriteLock();
- this.cache = new HashMap<>();
- this.typeCache = new HashMap<>();
+ public ConfigurationBasedChannelRegistry(EventLogConfiguration cfg, SinkRegistry sinkRegistry) {
+ this.cache = new AtomicReference<>(new HashMap<>());
+ this.typeCache = new AtomicReference<>(new HashMap<>());
this.sinkRegistry = sinkRegistry;
cfg.channels().listen(new CacheUpdater());
}
@Override
public EventChannel getByName(String name) {
- guard.readLock().lock();
- try {
- return cache.get(name);
- } finally {
- guard.readLock().unlock();
- }
+ return cache.get().get(name);
}
@Override
public Set<EventChannel> findAllChannelsByEventType(String igniteEventType) {
- guard.readLock().lock();
- try {
- Set<EventChannel> result = typeCache.get(igniteEventType);
- return result == null ? Set.of() : new HashSet<>(result);
- } finally {
- guard.readLock().unlock();
- }
+ Set<EventChannel> result = typeCache.get().get(igniteEventType);
+ return result == null ? Set.of() : new HashSet<>(result);
Review Comment:
No need to copy `result`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander merged PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#discussion_r1906724792
##########
modules/eventlog/src/main/java/org/apache/ignite/internal/eventlog/api/EventLog.java:
##########
@@ -44,7 +44,16 @@ public interface EventLog {
/**
* Writes event into every channel this event relates to.
*
- * @param eventProvider Event provider.
+ * @param event The event to log.
*/
- void log(Supplier<Event> eventProvider);
+ void log(Event event);
+
+ /**
+ * Lazy version of {@link #log(Event)}. It first checks if the events of the given type are enabled and then logs the event.
+ * INVARIANT: type must be a valid event type and eventProvider must provide an event of the same type.
+ *
+ * @param type the type of the event.
+ * @param eventProvider the event provider.
+ */
+ void log(String type, Supplier<Event> eventProvider);
Review Comment:
Why do we use type as String instead of enum?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-24163 Optimize EventLog [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on PR #5004:
URL: https://github.com/apache/ignite-3/pull/5004#issuecomment-2578066594
@AMashenkov applied most of your suggestions. Also, added a couple of additional optimizations (return null instead of empty collection) witch have improved the performance of the critical path.
The PR now is ready for review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org