ekaterinadimitrova2 commented on code in PR #2488:
URL: https://github.com/apache/cassandra/pull/2488#discussion_r1270721681
##########
src/java/org/apache/cassandra/audit/BinAuditLogger.java:
##########
@@ -98,6 +99,11 @@ public void log(AuditLogEntry auditLogEntry)
@VisibleForTesting
public static class Message extends BinLog.ReleaseableWriteMarshallable
implements WeightedQueue.Weighable
{
+ /**
+ * The shallow size of a {@code Query} object.
Review Comment:
* The shallow size of a {@code Message} object.
##########
src/java/org/apache/cassandra/fql/FullQueryLogger.java:
##########
@@ -366,17 +366,21 @@ public void writeMarshallablePayload(WireOut wire)
@Override
public int weight()
{
- return Ints.checkedCast(EMPTY_SIZE + ObjectSizes.sizeOf(query) +
super.fielsdSize());
+ // Object deep size = Object' shallow size + query field deep size
+ deep size of the parent fields
+ return Ints.checkedCast(EMPTY_SIZE + ObjectSizes.sizeOf(query) +
super.fieldsSize());
}
}
public static class Batch extends AbstractLogEntry
{
/**
- * The shallow size of a {@code Batch} object.
+ * The shallow size of a {@code Batch} object (which includes
primitive fields).
*/
private static final long EMPTY_SIZE = ObjectSizes.measure(new
Batch());
+ /**
+ * The way is pre-computed in the constructor and represent the object
deep size.
Review Comment:
* The weight is pre-computed in the constructor and represents the object's
deep size.
##########
src/java/org/apache/cassandra/fql/FullQueryLogger.java:
##########
@@ -508,16 +545,14 @@ public void release()
queryOptionsBuffer.release();
}
- @Override
- public int weight()
+ /**
+ * Returns the sum of the non primitive fields sizes.
+ * @return the sum of the non primitive fields sizes.
+ */
+ protected long fielsdSize()
{
- return OBJECT_HEADER_SIZE
- + Long.BYTES
// queryStartTime
- + Integer.BYTES
// protocolVersion
- + OBJECT_REFERENCE_SIZE + EMPTY_BYTEBUF_SIZE +
queryOptionsBuffer.capacity() // queryOptionsBuffer
- + Long.BYTES
// generatedTimestamp
- + Long.BYTES
// generatedNowInSeconds
- + OBJECT_REFERENCE_SIZE +
Ints.checkedCast(ObjectSizes.sizeOf(keyspace)); // keyspace
+ return EMPTY_BYTEBUF_SIZE + queryOptionsBuffer.capacity() //
queryOptionsBuffer
+ + ObjectSizes.sizeOf(keyspace); //
keyspace
Review Comment:
Thanks for the additional comments, adding stuff separately is quite
confusing even after looking into the MemoreMeter for months.... :(
##########
src/java/org/apache/cassandra/utils/ObjectSizes.java:
##########
@@ -105,15 +98,12 @@ public static long sizeOfReferenceArray(int length)
*/
public static long sizeOfArray(Object[] objects)
{
- if (objects == null)
- return 0;
-
- return sizeOfReferenceArray(objects.length);
+ return meter.measureArray(objects);
Review Comment:
My understanding is measureArray is doing what sizeOfReferenceArray (thus
the change you did here) is doing so I was wondering why then we do not replace
all usages of sizeOfReferenceArray with measureArray? But now on a second read
I see I misread, sizeOfReferenceArray is provided length...
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]