New post

Find

Question
· Nov 15, 2024

stream.Read() only reading in chunks of 1K

I use the following code to calculate the SHA1 of a file :

set stream = ##class(%Stream.FileBinary).%New()
do stream.LinkToFile(filename)
write $SYSTEM.Encryption.Base64Encode($SYSTEM.Encryption.SHA1HashStream(stream))

This code is called thousands of time and performance is critical. I have tried to code same logic in another language (which is lower level) and it's almost twice as fast. It's unclear why so I started investigating.

Using Process Monitor, it shows that files are read in chunks of 1024 bytes (1K) which is suboptimal. Reading a file of 1MB while require 1024 file system calls. Usually bigger buffer is used (eg : 4096 or 81920).

The SHA1HashStream() function is implemented this way : 

do $System.Encryption.SHAHashReset(160)
set sc=stream.Rewind() If $$$ISERR(sc) Quit ""
while 'stream.AtEnd {
	do $System.Encryption.SHAHashInput(160, stream.Read(32000,.sc))
	if $$$ISERR(sc) Quit
}
quit $System.Encryption.SHAHashResult(160)

stream.Read(32000) will do the following call :

Read:32000

So I except it to read the file in chunks of 32000 bytes, but that's not the case.

Is this excepted behavior ? Is there a way to change this ?

EDIT: I have been able to force 1024 bytes reads in the other language implementation and it's still about twice faster so performance issue is probably due to something else.

2 Comments
Discussion (2)1
Log in or sign up to continue
Article
· Nov 14, 2024 2m read

第二十一章 TCP 客户端 服务器通信 - 客户端OPEN命令

第二十一章 TCP 客户端 服务器通信 - 客户端OPEN命令

客户端OPEN命令

客户端OPEN命令与服务器端OPEN命令只有一个方面的不同:第一个设备参数必须指定要连接的主机。要指定主机,需要包括客户端识别为主机的名称或Internet地址。

一旦建立连接,OPEN开就会成功。此时,可以读取或写入该TCP设备。但是,如果连接的服务器端是另一个IRIS进程,则在使用WRITE命令将一些数据从客户端发送到服务器之前,服务器不会完成其连接端。因此,必须在发出任何读取命令之前发出写入命令。

客户端 OPEN 命令的一些示例是:

Discussion (0)1
Log in or sign up to continue
Question
· Nov 14, 2024

Having problems passing-through an X12 message. What am I missing?

What settings do I need to just passthrough an X12 messages from a BS to BO and out the BO without modifying the message?

Currently, we are receiving the X12 messages but, it seems Iris is modifying it by "hiding" some segments like the ISA segment. The message goes out the BO modified and it doesn't reach its destination. Since I just want to pass it through, there is no BP, DTL, or Rule processing the message. Message is received by the BS and sent directly to the BO. 

My current settings:

  1. The BS is set as
    • TCP with Class Name: EnsLib.EDI.X12.Service.TCPService
    • Adapter Class Name: EnsLib.EDI.X12.Adapter.TCPInboundAdapter
    • Doc Schema Category: HIPAA_5010
    • Batch Handling: Individual
    • Framing: None
7 Comments
Discussion (7)2
Log in or sign up to continue
Announcement
· Nov 14, 2024

[Video] Using iService for Cloud Product Support

Hi, Community!

Are you using InterSystems Cloud Services? See how to get support directly in the app:

Using iService for Cloud Product Support

In this video, you will learn how to:

  • Initiate and manage a support request.
  • Create a new ticket.

Using iService, you can interact with InterSystems support staff and quickly resolve an issue.

Discussion (0)1
Log in or sign up to continue
Article
· Nov 14, 2024 1m read

How to control the order of columns displayed when accessing from an ODBC tool

InterSystems FAQ rubric

By default, the order of columns in a table is determined automatically by the system. To change the order, explicitly set the order for each property using the property keyword SqlColumnNumber when defining the class.

Example:

Property Name As %String [SqlColumnNumber = 2];

Please see the documentation below.

SqlColumnNumber

If you want to change the SQL table name, specify SqlTableName. If you want to change the column name (field name), specify SqlFieldName.

Both apply only to persistent classes.

Discussion (0)0
Log in or sign up to continue